﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AdoNET
{
    class Program
    {
        static void Main(string[] args)
        {
            Adapter adapter = new Adapter();

            // 1.	Method return list of products that have price < 200 and product name Bxxxx
            IList<Product> products = adapter.Read();
            foreach (Product product in products)
            {
                Console.WriteLine("ID: {0}, Name: {1}, Price: {2}", product.ProductId, product.ProductName, product.Price);
            }

            // 2.	Method return a product with productId = 3
            Product product2 = adapter.FindByProductId(3);
            Console.WriteLine("ID: {0}, Name: {1}, Price: {2}", product2.ProductId, product2.ProductName, product2.Price);

            // 3.	Method update a product, and return the product
            Product product3 = adapter.UpdateByProductId(3, 20);
            Console.WriteLine("updated");
            Console.WriteLine("ID: {0}, Name: {1}, Price: {2}", product3.ProductId, product3.ProductName, product3.Price);
            

            //4.	Method update a product with product name = Exxxx (use transaction to cancel the update), and return boolean
            bool status = adapter.UpdateByProductName("E%", 500);
            Console.WriteLine("Updated : {0}", status.ToString());

            // 5.	Method delete a product
            adapter.Delete(4);
            Console.WriteLine("Deleted");
            Console.Read();
        }
    }
}
